<?php
include_once './vendor/autoload.php';

function dd($var){
//    echo __FILE__;
    echo '<br><pre>';
    print_r($var);
    echo '</pre>';
    die;
}
//新加方法 暂时用不到
function get_file_mimetype($filePath){
    $finfo    = finfo_open(FILEINFO_MIME);
    $mimetype = finfo_file($finfo, $filePath);
    finfo_close($finfo);
    return $mimetype;
}

$url = \Wcs\WcsFile::UploadMkblk('hotcast-test001','bigvideo.mp4','flm.mp4');
dd($url);

//提示信息
function print_help() {
    echo "Usage: php text.php [-h | --help] -b <bucketName> -f <fileKey> -l <localFile>\n\r";
}
$opts = "h:b:f:l:";
$longopts = ['help'];
$options = getopt($opts,$longopts);

if(isset($options['h']) || isset($options['help']) || empty($options)){
    print_help();
    exit(0);
}

if(!isset($options['f']) || !isset($options['b'])){
    echo 'please input bucketName and filekey';
    exit(0);
}

$options['f'] = isset($options['f'])? $options['f'] : 'test_video1.mp4';
$options['b'] = isset($options['b'])? $options['b'] : 'hotcast-test001';
//print_r($options);

$url = \Wcs\WcsFile::getFileInfo($options['b'],$options['f']);
print_r($url);



//$arr = getopt('a:b:');
//print_r($arr);
//$fp = fopen('./bigvideo.mp4.rcd', 'r');
//fseek($fp, -1024,SEEK_END);

// read some data
//$data = fgets($fp, 4096);
//var_dump($data);
//$data = exec("tail -1 ./bigvideo.mp4.rcd");
//var_dump($data);